


   $(function () {
       closeP();
       clickShow();
       clickHidden();
       //getTv();
       function closeP() {
           $('.mm_BottomBar > a:first-child').on('click',function () {
               $('.mm_BottomBar').fadeOut();
               $('.mm_end > p').css('marginBottom',0)
           })
       }

       function clickShow() {
           $('.shopCol > .fourth').on('click',function () {
             $('.shaiXuan').animate({left:0},300);
               $('.mask').animate({left:0},10);
           })
       }

       function clickHidden() {
           $('.shaiXuan > .head > .iconfont').on('click',function () {
               $('.shaiXuan').animate({left:-20000},300);
               $('.mask').animate({left:-20000},100);
           })
       }


       //通过页面提供的url地址，将url数据中的有效信息提取出来
       var url = window.location.search;    //这里从对应的HTML页面内得到url中问号后的内容
       console.log(url);
       console.log(url.replace(/[^0-9]/g, ""));     //这里对得到的字符串进行替换，仅得到匹配到的数字
       var page = 1;
       var cat = url.replace(/[^0-9]/g, "");

       function getProduct(categoryId,pageId) {
           $.ajax({
                url:'http://139.199.157.195:9090/api/getproductlist?categoryid=' + categoryId + '&pageid=' + pageId + '',
                success:function (res) {
                //console.log(res.result);
                var html = template('tpl22',res);
                $('.product').prepend(html);
            }
        })
       }

       getProduct(cat,page);

       $(".next").on("click",function(){
           page++;
           getProduct(cat, page);
       })

       $(".previous").on("click",function(){
           page--;
           if (page==1){
               alert('已经是第一页')
           }else{
               getProduct(cat, page);
           }
       })

   })


